import 'package:flutter/material.dart';

import 'package:get/get.dart';
import "package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart";
import '../controllers/home_controller.dart';

class HomeView extends GetView<HomeController> {
  const HomeView({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('直播列表'), centerTitle: true),
      body: Container(
        color: Color(0xFFF9F9F9),
        padding: EdgeInsets.all(20.0),
        child: MasonryGridView.count(
          crossAxisCount: 2, // 每行2列
          mainAxisSpacing: 10,
          crossAxisSpacing: 20,
          itemCount: 2, // 数据总数
          itemBuilder: (context, index) {
            return Container(
              // color: Color(0xFFFFFFFF),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10.0),
                color: Color(0xFFFFFFFF),
                boxShadow: [
                  BoxShadow(
                    color: Color(0xFF000000).withValues(alpha: 0.1),
                    blurRadius: 10.0,
                    spreadRadius: 0.0,
                    offset: Offset(0.0, 0.0),
                  ),
                ],
              ),
              clipBehavior: Clip.antiAlias,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Image.network(
                    'https://t14.baidu.com/it/u=1374867937,2347489704&fm=58&app=83&size=w931&n=0&f=JPEG&fmt=auto?sec=1743094800&t=c1481ff92c4e229d49a57eb72ead6a0c',
                    width: double.infinity,
                    fit: BoxFit.fill,
                  ),
                  Padding(
                    padding: EdgeInsets.all(10.0),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        SizedBox(
                          child: Text(
                            index % 2 == 0
                                ? '直播标题直播标题直播标题直播标题直播标题直播标题直播标题直播标题':
                            '直播标',
                            style: TextStyle(
                              fontSize: 18.0,
                              fontWeight: FontWeight.bold,
                              overflow: TextOverflow.ellipsis,
                            ),
                            maxLines: 2,
                          ),
                        ),

                        SizedBox(height: 20.0),
                        Row(
                          children: [
                            ClipOval(
                              child: Image.network(
                                'https://t14.baidu.com/it/u=1374867937,2347489704&fm=58&app=83&size=w931&n=0&f=JPEG&fmt=auto?sec=1743094800&t=c1481ff92c4e229d49a57eb72ead6a0c',
                                height: 30.0,
                                width: 30.0,
                                fit: BoxFit.cover,
                              ),
                            ),
                            SizedBox(width: 10.0),
                            Expanded(
                              child: Text(
                                '主播姓名主播姓名主播姓名主播姓名主播姓名',
                                style: TextStyle(
                                  fontSize: 14.0,
                                  overflow: TextOverflow.ellipsis,
                                ),
                              ),
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            );
          },
        ),
      ),
    );
  }
}
